/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MENU_EDIT.java
 *
 * Created on Oct 5, 2010, 9:17:02 PM
 */

package Java;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import java.sql.SQLException;

/**
 *
 * @author akmal
 */
public class MENU_EDIT extends javax.swing.JFrame {

    private String url = "jdbc:oracle:thin:@localhost:1521:XE";
    private String userID = "HR";
    private String userPW = "hr";
    String food;
    String selection;
    String newline = "\n";
    Connection con;
    ResultSet rset;
    Statement stmt;

    /** Creates new form MENU_EDIT */
    public MENU_EDIT()
    {
        super("MENU PROFILE");
        initComponents();
        this.setLocationRelativeTo(null);
        connectDatabase();
        takeout();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        DoneButton = new javax.swing.JButton();
        CategoryTabbedPane = new javax.swing.JTabbedPane();
        AppPane = new javax.swing.JPanel();
        jLayeredPane2 = new javax.swing.JLayeredPane();
        jLabel2 = new javax.swing.JLabel();
        APPfield = new javax.swing.JTextField();
        Find = new javax.swing.JButton();
        Reset = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        FoodCode = new javax.swing.JTextField();
        FoodType = new javax.swing.JTextField();
        FoodName = new javax.swing.JTextField();
        FoodPrice = new javax.swing.JTextField();
        add = new javax.swing.JButton();
        update = new javax.swing.JButton();
        delete = new javax.swing.JButton();
        indication = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        MainDishPane = new javax.swing.JPanel();
        jLayeredPane3 = new javax.swing.JLayeredPane();
        jLabel7 = new javax.swing.JLabel();
        MDfield = new javax.swing.JTextField();
        Find1 = new javax.swing.JButton();
        Reset1 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        FoodCode1 = new javax.swing.JTextField();
        FoodType1 = new javax.swing.JTextField();
        FoodName1 = new javax.swing.JTextField();
        FoodPrice1 = new javax.swing.JTextField();
        add1 = new javax.swing.JButton();
        update1 = new javax.swing.JButton();
        delete1 = new javax.swing.JButton();
        indication1 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        DessertPane = new javax.swing.JPanel();
        jLayeredPane4 = new javax.swing.JLayeredPane();
        jLabel12 = new javax.swing.JLabel();
        FilledField2 = new javax.swing.JTextField();
        Find2 = new javax.swing.JButton();
        Reset2 = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        FoodCode2 = new javax.swing.JTextField();
        FoodType2 = new javax.swing.JTextField();
        FoodName2 = new javax.swing.JTextField();
        FoodPrice2 = new javax.swing.JTextField();
        add2 = new javax.swing.JButton();
        update2 = new javax.swing.JButton();
        delete2 = new javax.swing.JButton();
        indication2 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        DrinkPane = new javax.swing.JPanel();
        jLayeredPane5 = new javax.swing.JLayeredPane();
        jLabel17 = new javax.swing.JLabel();
        FilledField3 = new javax.swing.JTextField();
        Find3 = new javax.swing.JButton();
        Reset3 = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        FoodCode3 = new javax.swing.JTextField();
        FoodType3 = new javax.swing.JTextField();
        FoodName3 = new javax.swing.JTextField();
        FoodPrice3 = new javax.swing.JTextField();
        add3 = new javax.swing.JButton();
        update3 = new javax.swing.JButton();
        delete3 = new javax.swing.JButton();
        indication3 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        ViewAllPane = new javax.swing.JPanel();
        jLayeredPane6 = new javax.swing.JLayeredPane();
        SearchBy4 = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        FoodArea = new javax.swing.JTextArea();
        jLabel28 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jSeparator1.setBounds(0, 50, 700, 10);
        jLayeredPane1.add(jSeparator1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jSeparator2.setBounds(0, 420, 700, 20);
        jLayeredPane1.add(jSeparator2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        DoneButton.setFont(new java.awt.Font("Times New Roman", 1, 12));
        DoneButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        DoneButton.setText("DONE");
        DoneButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        DoneButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DoneButtonActionPerformed(evt);
            }
        });
        DoneButton.setBounds(580, 430, 100, 40);
        jLayeredPane1.add(DoneButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        CategoryTabbedPane.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                CategoryTabbedPaneFocusGained(evt);
            }
        });

        jLabel2.setText("Search Code :");
        jLabel2.setBounds(110, 10, 100, 30);
        jLayeredPane2.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);
        APPfield.setBounds(210, 10, 130, 30);
        jLayeredPane2.add(APPfield, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Find.setFont(new java.awt.Font("Times New Roman", 1, 12));
        Find.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Find.setText("FIND");
        Find.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Find.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FindActionPerformed(evt);
            }
        });
        Find.setBounds(430, 10, 100, 30);
        jLayeredPane2.add(Find, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Reset.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        Reset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Reset.setText("CLEAR");
        Reset.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetActionPerformed(evt);
            }
        });
        Reset.setBounds(220, 270, 100, 30);
        jLayeredPane2.add(Reset, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel3.setText("FOOD CODE :");
        jLabel3.setBounds(50, 74, 110, 40);
        jLayeredPane2.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setText("FOOD TYPE  :");
        jLabel4.setBounds(50, 130, 110, 30);
        jLayeredPane2.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setText("FOOD NAME :");
        jLabel5.setBounds(50, 174, 110, 40);
        jLayeredPane2.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setText("FOOD PRICE :");
        jLabel6.setBounds(50, 220, 110, 40);
        jLayeredPane2.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodCode.setBounds(210, 80, 130, 30);
        jLayeredPane2.add(FoodCode, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodType.setText("Appetizer");
        FoodType.setFocusable(false);
        FoodType.setBounds(210, 130, 130, 30);
        jLayeredPane2.add(FoodType, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodName.setBounds(210, 180, 130, 30);
        jLayeredPane2.add(FoodName, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodPrice.setBounds(210, 230, 130, 30);
        jLayeredPane2.add(FoodPrice, javax.swing.JLayeredPane.DEFAULT_LAYER);

        add.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        add.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        add.setText("ADD");
        add.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        add.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addActionPerformed(evt);
            }
        });
        add.setBounds(430, 90, 100, 40);
        jLayeredPane2.add(add, javax.swing.JLayeredPane.DEFAULT_LAYER);

        update.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        update.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        update.setText("UPDATE");
        update.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        update.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateActionPerformed(evt);
            }
        });
        update.setBounds(430, 150, 100, 40);
        jLayeredPane2.add(update, javax.swing.JLayeredPane.DEFAULT_LAYER);

        delete.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        delete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        delete.setText("DELETE");
        delete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        delete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteActionPerformed(evt);
            }
        });
        delete.setBounds(430, 210, 100, 40);
        jLayeredPane2.add(delete, javax.swing.JLayeredPane.DEFAULT_LAYER);
        indication.setBounds(80, 50, 260, 20);
        jLayeredPane2.add(indication, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel24.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        jLabel24.setBounds(0, 0, -1, 340);
        jLayeredPane2.add(jLabel24, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout AppPaneLayout = new javax.swing.GroupLayout(AppPane);
        AppPane.setLayout(AppPaneLayout);
        AppPaneLayout.setHorizontalGroup(
            AppPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 608, Short.MAX_VALUE)
        );
        AppPaneLayout.setVerticalGroup(
            AppPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
        );

        CategoryTabbedPane.addTab("APPERTIZER", AppPane);

        jLabel7.setText("Search Code :");
        jLabel7.setBounds(110, 10, 100, 30);
        jLayeredPane3.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);
        MDfield.setBounds(210, 10, 130, 30);
        jLayeredPane3.add(MDfield, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Find1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        Find1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Find1.setText("FIND");
        Find1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Find1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Find1ActionPerformed(evt);
            }
        });
        Find1.setBounds(430, 10, 100, 30);
        jLayeredPane3.add(Find1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Reset1.setFont(new java.awt.Font("Times New Roman", 1, 12));
        Reset1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Reset1.setText("CLEAR");
        Reset1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Reset1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Reset1ActionPerformed(evt);
            }
        });
        Reset1.setBounds(220, 270, 100, 30);
        jLayeredPane3.add(Reset1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setText("FOOD CODE :");
        jLabel8.setBounds(50, 74, 110, 40);
        jLayeredPane3.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel9.setText("FOOD TYPE  :");
        jLabel9.setBounds(50, 130, 110, 30);
        jLayeredPane3.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel10.setText("FOOD NAME :");
        jLabel10.setBounds(50, 174, 110, 40);
        jLayeredPane3.add(jLabel10, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel11.setText("FOOD PRICE :");
        jLabel11.setBounds(50, 224, 110, 40);
        jLayeredPane3.add(jLabel11, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodCode1.setBounds(210, 80, 130, 30);
        jLayeredPane3.add(FoodCode1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodType1.setText("Main Dish");
        FoodType1.setFocusable(false);
        FoodType1.setBounds(210, 130, 130, 30);
        jLayeredPane3.add(FoodType1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodName1.setBounds(210, 180, 130, 30);
        jLayeredPane3.add(FoodName1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodPrice1.setBounds(210, 230, 130, 30);
        jLayeredPane3.add(FoodPrice1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        add1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        add1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        add1.setText("ADD");
        add1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        add1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                add1ActionPerformed(evt);
            }
        });
        add1.setBounds(430, 90, 100, 40);
        jLayeredPane3.add(add1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        update1.setFont(new java.awt.Font("Times New Roman", 1, 12));
        update1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        update1.setText("UPDATE");
        update1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        update1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                update1ActionPerformed(evt);
            }
        });
        update1.setBounds(430, 150, 100, 40);
        jLayeredPane3.add(update1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        delete1.setFont(new java.awt.Font("Times New Roman", 1, 12));
        delete1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        delete1.setText("DELETE");
        delete1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        delete1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                delete1ActionPerformed(evt);
            }
        });
        delete1.setBounds(430, 210, 100, 40);
        jLayeredPane3.add(delete1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        indication1.setBounds(80, 50, 260, 20);
        jLayeredPane3.add(indication1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        jLabel25.setBounds(0, 0, -1, 340);
        jLayeredPane3.add(jLabel25, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout MainDishPaneLayout = new javax.swing.GroupLayout(MainDishPane);
        MainDishPane.setLayout(MainDishPaneLayout);
        MainDishPaneLayout.setHorizontalGroup(
            MainDishPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 608, Short.MAX_VALUE)
        );
        MainDishPaneLayout.setVerticalGroup(
            MainDishPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
        );

        CategoryTabbedPane.addTab("MAIN DISH", MainDishPane);

        jLabel12.setText("Search Code :");
        jLabel12.setBounds(110, 10, 100, 30);
        jLayeredPane4.add(jLabel12, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FilledField2.setBounds(210, 10, 130, 30);
        jLayeredPane4.add(FilledField2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Find2.setFont(new java.awt.Font("Times New Roman", 1, 12));
        Find2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Find2.setText("FIND");
        Find2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Find2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Find2ActionPerformed(evt);
            }
        });
        Find2.setBounds(430, 10, 100, 30);
        jLayeredPane4.add(Find2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Reset2.setFont(new java.awt.Font("Times New Roman", 1, 12));
        Reset2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Reset2.setText("CLEAR");
        Reset2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Reset2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Reset2ActionPerformed(evt);
            }
        });
        Reset2.setBounds(220, 270, 100, 30);
        jLayeredPane4.add(Reset2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel13.setText("FOOD CODE :");
        jLabel13.setBounds(50, 74, 110, 40);
        jLayeredPane4.add(jLabel13, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel14.setText("FOOD TYPE  :");
        jLabel14.setBounds(50, 130, 110, 30);
        jLayeredPane4.add(jLabel14, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel15.setText("FOOD NAME :");
        jLabel15.setBounds(50, 180, 110, 30);
        jLayeredPane4.add(jLabel15, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel16.setText("FOOD PRICE :");
        jLabel16.setBounds(50, 230, 110, 30);
        jLayeredPane4.add(jLabel16, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodCode2.setBounds(210, 80, 130, 30);
        jLayeredPane4.add(FoodCode2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodType2.setText("Dessert");
        FoodType2.setFocusable(false);
        FoodType2.setBounds(210, 130, 130, 30);
        jLayeredPane4.add(FoodType2, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodName2.setBounds(210, 180, 130, 30);
        jLayeredPane4.add(FoodName2, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodPrice2.setBounds(210, 230, 130, 30);
        jLayeredPane4.add(FoodPrice2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        add2.setFont(new java.awt.Font("Times New Roman", 1, 12));
        add2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        add2.setText("ADD");
        add2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        add2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                add2ActionPerformed(evt);
            }
        });
        add2.setBounds(430, 90, 100, 40);
        jLayeredPane4.add(add2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        update2.setFont(new java.awt.Font("Times New Roman", 1, 12));
        update2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        update2.setText("UPDATE");
        update2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        update2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                update2ActionPerformed(evt);
            }
        });
        update2.setBounds(430, 150, 100, 40);
        jLayeredPane4.add(update2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        delete2.setFont(new java.awt.Font("Times New Roman", 1, 12));
        delete2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        delete2.setText("DELETE");
        delete2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        delete2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                delete2ActionPerformed(evt);
            }
        });
        delete2.setBounds(430, 210, 100, 40);
        jLayeredPane4.add(delete2, javax.swing.JLayeredPane.DEFAULT_LAYER);
        indication2.setBounds(80, 50, 260, 20);
        jLayeredPane4.add(indication2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        jLabel26.setBounds(0, 0, -1, 340);
        jLayeredPane4.add(jLabel26, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout DessertPaneLayout = new javax.swing.GroupLayout(DessertPane);
        DessertPane.setLayout(DessertPaneLayout);
        DessertPaneLayout.setHorizontalGroup(
            DessertPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 608, Short.MAX_VALUE)
        );
        DessertPaneLayout.setVerticalGroup(
            DessertPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
        );

        CategoryTabbedPane.addTab("DESSERT", DessertPane);

        jLabel17.setText("Search Code :");
        jLabel17.setBounds(110, 10, 100, 30);
        jLayeredPane5.add(jLabel17, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FilledField3.setBounds(210, 10, 130, 30);
        jLayeredPane5.add(FilledField3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Find3.setFont(new java.awt.Font("Times New Roman", 1, 12));
        Find3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Find3.setText("FIND");
        Find3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Find3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Find3ActionPerformed(evt);
            }
        });
        Find3.setBounds(430, 10, 100, 30);
        jLayeredPane5.add(Find3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Reset3.setFont(new java.awt.Font("Times New Roman", 1, 12));
        Reset3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Reset3.setText("CLEAR");
        Reset3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Reset3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Reset3ActionPerformed(evt);
            }
        });
        Reset3.setBounds(220, 270, 100, 30);
        jLayeredPane5.add(Reset3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel18.setText("FOOD CODE :");
        jLabel18.setBounds(50, 74, 110, 40);
        jLayeredPane5.add(jLabel18, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel19.setText("FOOD TYPE  :");
        jLabel19.setBounds(50, 130, 110, 30);
        jLayeredPane5.add(jLabel19, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel20.setText("FOOD NAME :");
        jLabel20.setBounds(50, 174, 110, 40);
        jLayeredPane5.add(jLabel20, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel21.setText("FOOD PRICE :");
        jLabel21.setBounds(50, 224, 110, 40);
        jLayeredPane5.add(jLabel21, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodCode3.setBounds(210, 80, 130, 30);
        jLayeredPane5.add(FoodCode3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodType3.setText("Drink");
        FoodType3.setFocusable(false);
        FoodType3.setBounds(210, 130, 130, 30);
        jLayeredPane5.add(FoodType3, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodName3.setBounds(210, 180, 130, 30);
        jLayeredPane5.add(FoodName3, javax.swing.JLayeredPane.DEFAULT_LAYER);
        FoodPrice3.setBounds(210, 230, 130, 30);
        jLayeredPane5.add(FoodPrice3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        add3.setFont(new java.awt.Font("Times New Roman", 1, 12));
        add3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        add3.setText("ADD");
        add3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        add3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                add3ActionPerformed(evt);
            }
        });
        add3.setBounds(430, 90, 100, 40);
        jLayeredPane5.add(add3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        update3.setFont(new java.awt.Font("Times New Roman", 1, 12));
        update3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        update3.setText("UPDATE");
        update3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        update3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                update3ActionPerformed(evt);
            }
        });
        update3.setBounds(430, 150, 100, 40);
        jLayeredPane5.add(update3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        delete3.setFont(new java.awt.Font("Times New Roman", 1, 12));
        delete3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        delete3.setText("DELETE");
        delete3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        delete3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                delete3ActionPerformed(evt);
            }
        });
        delete3.setBounds(430, 210, 100, 40);
        jLayeredPane5.add(delete3, javax.swing.JLayeredPane.DEFAULT_LAYER);
        indication3.setBounds(80, 50, 260, 20);
        jLayeredPane5.add(indication3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel27.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        jLabel27.setBounds(0, 0, -1, 340);
        jLayeredPane5.add(jLabel27, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout DrinkPaneLayout = new javax.swing.GroupLayout(DrinkPane);
        DrinkPane.setLayout(DrinkPaneLayout);
        DrinkPaneLayout.setHorizontalGroup(
            DrinkPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addComponent(jLayeredPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 608, Short.MAX_VALUE)
        );
        DrinkPaneLayout.setVerticalGroup(
            DrinkPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addGap(0, 299, Short.MAX_VALUE)
            .addComponent(jLayeredPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
        );

        CategoryTabbedPane.addTab("DRINK", DrinkPane);

        SearchBy4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Food Code", "Food Name" }));
        SearchBy4.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                SearchBy4PropertyChange(evt);
            }
        });
        SearchBy4.setBounds(220, 10, 170, 30);
        jLayeredPane6.add(SearchBy4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel22.setText("Search By :");
        jLabel22.setBounds(140, 10, 90, 30);
        jLayeredPane6.add(jLabel22, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodArea.setColumns(20);
        FoodArea.setRows(5);
        jScrollPane1.setViewportView(FoodArea);

        jScrollPane1.setBounds(180, 50, 240, 210);
        jLayeredPane6.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel28.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        jLabel28.setBounds(0, 0, 640, 340);
        jLayeredPane6.add(jLabel28, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout ViewAllPaneLayout = new javax.swing.GroupLayout(ViewAllPane);
        ViewAllPane.setLayout(ViewAllPaneLayout);
        ViewAllPaneLayout.setHorizontalGroup(
            ViewAllPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 608, Short.MAX_VALUE)
        );
        ViewAllPaneLayout.setVerticalGroup(
            ViewAllPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
        );

        CategoryTabbedPane.addTab("VIEW ALL", ViewAllPane);

        CategoryTabbedPane.setBounds(40, 70, 620, 340);
        jLayeredPane1.add(CategoryTabbedPane, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18));
        jLabel1.setText("MENU PROFILE");
        jLabel1.setBounds(40, 10, 310, 50);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract2.jpg"))); // NOI18N
        jLabel23.setBounds(0, 0, 700, 500);
        jLayeredPane1.add(jLabel23, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    // ADD APPETIZER
    private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed

        String appetizerCode = FoodCode.getText();
        String appetizerType = FoodType.getText();
        String appetizerName = FoodName.getText();
        String appetizerPrice= FoodPrice.getText();

        String query = "INSERT INTO FOOD VALUES("+appetizerCode+",'"+appetizerType+"','"+appetizerName+"',"+appetizerPrice+")";
        String message = "Do you want to add a new detail ?";
        String TITLE = "Confirmation?";

        int reply = JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION){

            try
            {
                stmt = con.createStatement();
                stmt.executeUpdate(query);
                JOptionPane.showMessageDialog(null, "Add successful.");
                clear();
            }
            catch (SQLException ex)
            {
                 JOptionPane.showMessageDialog(null, "Add failed!\nDuplication is not allowed!");
            }
        }
        clear();
        FoodArea.setText("");
        takeout(); // USED TO POPULATED THE "FOOD AREA" 
    }//GEN-LAST:event_addActionPerformed

    private void ResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResetActionPerformed

        FoodCode.setText("");
        FoodName.setText("");
        FoodPrice.setText("");
        APPfield.setText("");
    }//GEN-LAST:event_ResetActionPerformed

    //DELETE APPETIZER
    private void deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteActionPerformed
        
        food = APPfield.getText();
        String query = "DELETE FROM FOOD WHERE FOOD_CODE = "+food+""; 
        String message = "Are you sure want to delete this menu profile ?";
        String title2 = "Confirmation?";
        
        // display the JOptionPane showConfirmDialog
        int reply = JOptionPane.showConfirmDialog(null, message, title2, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)//delete from database once the user click "YES"
        {
            try
            {
                stmt = con.createStatement();
                stmt.executeUpdate(query);
                JOptionPane.showMessageDialog(null, "Delete successful.");
            }
            catch (Exception ex)
            {
                JOptionPane.showMessageDialog(null, "Delete failed.");
                // Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
            }
            clear();
        }
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_deleteActionPerformed

    // SEARCH .
    private void SearchBy4PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_SearchBy4PropertyChange

        
        SearchBy4.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e)
            {
                if (SearchBy4.getSelectedIndex() == 0)
                {
                    FoodArea.setText("");
                    takeout();
                    try
                    {
                        while (rset.next())
                        {
                            FoodArea.append(rset.getInt(1) + newline);
                        }
                    } 
                    catch (Exception ex)
                    {
                        //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                else if ( SearchBy4.getSelectedIndex()== 1)
                {
                    FoodArea.setText("");
                    takeout();
                    try
                    {
                        while (rset.next())
                        {
                            FoodArea.append(rset.getString(3) + newline);
                        }
                    } 
                    catch (SQLException ex)
                    {
                        //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    }
                 }
            }
        });
    }//GEN-LAST:event_SearchBy4PropertyChange

    // FIND APPETIZER
    private void FindActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FindActionPerformed

       String appetizer = APPfield.getText();
       String query= "SELECT * FROM FOOD WHERE FOOD_CODE="+ appetizer +"";
       
       try
       {
            rset = getResultSet(query);
            if(rset.next())
            {
                FoodCode.setText(rset.getString("FOOD_CODE"));
                FoodType.setText(rset.getString("FOOD_TYPE"));
                FoodName.setText(rset.getString("FOOD_NAME"));
                FoodPrice.setText(rset.getString("FOOD_PRICE"));
            }
            else
            {
                JOptionPane.showMessageDialog(null, "INVALID APPETIZER.");
            }


        } 
       catch (Exception ex)
       {
          // JOptionPane.showMessageDialog(null, "INVALID APPETIZER.");
           // Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
       }
    }//GEN-LAST:event_FindActionPerformed

    private void CategoryTabbedPaneFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_CategoryTabbedPaneFocusGained
        // TODO add your handling code here:
    }//GEN-LAST:event_CategoryTabbedPaneFocusGained

    private void DoneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DoneButtonActionPerformed

        this.setVisible(false);
        new EMPLOYEE_MENU().setVisible(true);

    }//GEN-LAST:event_DoneButtonActionPerformed

    //UPDATE APPETIZER
    private void updateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateActionPerformed

        String appetizerCode = FoodCode.getText();
        String appetizerType = FoodType.getText();
        String appetizerName = FoodName.getText();
        String appetizerPrice= FoodPrice.getText();

        String query = "UPDATE FOOD SET FOOD_CODE = "+appetizerCode+",FOOD_TYPE = '"+appetizerType+"'"+
                        ",FOOD_NAME = '"+appetizerName+"',FOOD_PRICE = "+appetizerPrice+" WHERE FOOD_CODE = "+appetizerCode+"";
        String message = "Do you want to update the new detail ?";
        String TITLE = "Confirmation?";

        int reply = JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)
        {
            try
            {
                    stmt = con.createStatement();
                    stmt.executeUpdate(query);
                    JOptionPane.showMessageDialog(null, "Update successful.");
            }
            catch (Exception ex)
            {
                    //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(null, "Update failed!\nDuplication is not allowed!");
            }
        }
        clear();
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_updateActionPerformed

    //FIND MAIN DISH
    private void Find1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Find1ActionPerformed

       String mainDish = MDfield.getText();
       String query = "SELECT * FROM FOOD WHERE FOOD_CODE="+mainDish+"";
       try
       {
            rset = getResultSet(query);
            if(rset.next())
            {
                FoodCode1.setText(rset.getString("FOOD_CODE"));
                FoodType1.setText(rset.getString("FOOD_TYPE"));
                FoodName1.setText(rset.getString("FOOD_NAME"));
                FoodPrice1.setText(rset.getString("FOOD_PRICE"));
            }
            else
            {
                JOptionPane.showMessageDialog(null, "INVALID MAIN DISH.");
            }
        } 
       catch (Exception ex)
       {
           //JOptionPane.showMessageDialog(null, "INVALID MAIN DISH.");
           //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
       }
    }//GEN-LAST:event_Find1ActionPerformed

    private void Reset1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Reset1ActionPerformed

        FoodCode1.setText("");
        FoodName1.setText("");
        FoodPrice1.setText("");
        MDfield.setText("");
    }//GEN-LAST:event_Reset1ActionPerformed

    // ADD MAIN DISH
    private void add1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add1ActionPerformed

        String MainDishCode = FoodCode1.getText();
        String MainDishType = FoodType1.getText();
        String MainDishName = FoodName1.getText();
        String MainDishPrice= FoodPrice1.getText();

        String query = "INSERT INTO FOOD VALUES("+MainDishCode+",'"+MainDishType+"','"+MainDishName+"',"+MainDishPrice+")";
        String message = "Do you want to add a new detail ?";
        String TITLE = "Confirmation?";
        int reply = JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)
        {
            try
            {
                    stmt = con.createStatement();
                    stmt.executeUpdate(query);
                    JOptionPane.showMessageDialog(null, "Add successful.");
            }
            catch (Exception ex)
            {
                    //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(null, "Add failed!\nDuplication is not allowed!");
            }
        }
        clear1();
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_add1ActionPerformed

    // UPDATE MAIN DISH
    private void update1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_update1ActionPerformed

        String MainDishCode = FoodCode1.getText();
        String MainDishType = FoodType1.getText();
        String MainDishName = FoodName1.getText();
        String MainDishPrice= FoodPrice1.getText();

        String query = "UPDATE FOOD SET FOOD_CODE = "+MainDishCode+",FOOD_TYPE = '"+MainDishType+"'"+
                        ",FOOD_NAME = '"+MainDishName+"',FOOD_PRICE = "+MainDishPrice+" WHERE FOOD_CODE = "+MainDishCode+"";
        String message = "Do you want to update the new detail ?";
        String TITLE = "Confirmation?";
        int reply = JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)
        {
            try
            {
                    stmt = con.createStatement();
                    stmt.executeUpdate(query);
                    JOptionPane.showMessageDialog(null, "Update successful.");
            }
            catch (Exception ex)
            {
                    //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(null, "Update failed!\nDuplication is not allowed!");
            }
        }
        clear1();
        FoodArea.setText("");
        takeout();

    }//GEN-LAST:event_update1ActionPerformed

    // DELETE MAIN DISH
    private void delete1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delete1ActionPerformed

        food = MDfield.getText();
        String query= "DELETE FROM FOOD WHERE FOOD_CODE = "+food+"";
        String message = "Are you sure want to delete this menu profile ?";
        String title2 = "Confirmation?";

        // display the JOptionPane showConfirmDialog
        int reply = JOptionPane.showConfirmDialog(null, message, title2, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)//delete from database once the user click "YES"
        {
            try
            {
                stmt = con.createStatement();
                stmt.executeUpdate(query);
                JOptionPane.showMessageDialog(null, "Delete successful.");

            }
            catch (Exception ex)
            {
                JOptionPane.showMessageDialog(null, "Delete failed.");
                //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
            }
            clear1();
        }
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_delete1ActionPerformed

    // FIND DESSERT
    private void Find2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Find2ActionPerformed

       String dessert = FilledField2.getText();
       String query="SELECT * FROM FOOD WHERE FOOD_CODE="+dessert+"";
       try
       {
            rset = getResultSet(query);
            if(rset.next())
            {
                FoodCode2.setText(rset.getString("FOOD_CODE"));
                FoodType2.setText(rset.getString("FOOD_TYPE"));
                FoodName2.setText(rset.getString("FOOD_NAME"));
                FoodPrice2.setText(rset.getString("FOOD_PRICE"));
            }
            else
            {
                JOptionPane.showMessageDialog(null, "INVALID DESSERT !");
            }

        } 
        catch (Exception ex)
        {
            //JOptionPane.showMessageDialog(null, "INVALID DESSERT.");
            //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_Find2ActionPerformed

    private void Reset2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Reset2ActionPerformed

        FoodCode2.setText("");
        FoodName2.setText("");
        FoodPrice2.setText("");
        FilledField2.setText("");
    }//GEN-LAST:event_Reset2ActionPerformed

    // ADD DESSERT
    private void add2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add2ActionPerformed

        String DessertCode = FoodCode2.getText();
        String DessertType = FoodType2.getText();
        String DessertName = FoodName2.getText();
        String DessertPrice= FoodPrice2.getText();

        String query = "INSERT INTO FOOD VALUES("+DessertCode+",'"+DessertType+"','"+DessertName+"',"+DessertPrice+")";
        String message = "Do you want to add a new detail ?";
        String TITLE = "Confirmation?";
        int reply = JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)
        {
            try
            {
                    stmt = con.createStatement();
                    stmt.executeUpdate(query);
                    JOptionPane.showMessageDialog(null, "Add successful.");
                    clear();
            }
            catch (Exception ex)
            {
                    //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(null, "Add failed!\nDuplication is not allowed!");
            }
        }
        clear2();
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_add2ActionPerformed

    // UPDATE DESSERT
    private void update2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_update2ActionPerformed

        String DessertCode = FoodCode2.getText();
        String DessertType = FoodType2.getText();
        String DessertName = FoodName2.getText();
        String DessertPrice= FoodPrice2.getText();

        String query = "UPDATE FOOD SET FOOD_CODE = "+DessertCode+",FOOD_TYPE = '"+DessertType+"'"+
                        ",FOOD_NAME = '"+DessertName+"',FOOD_PRICE ="+DessertPrice+" WHERE FOOD_CODE = "+DessertCode+"";
        String message = "Do you want to update the new detail ?";
        String TITLE = "Confirmation?";
        int reply = JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)
        {
            try
            {
                    stmt = con.createStatement();
                    stmt.executeUpdate(query);
                    JOptionPane.showMessageDialog(null, "Update successful.");
            }
            catch (Exception ex)
            {
                    //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(null, "Update failed!\nDuplication is not allowed!");
            }
        }
        clear2();
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_update2ActionPerformed

    // DELETE DESSERT
    private void delete2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delete2ActionPerformed

        food = FilledField2.getText();
        String query = "DELETE FROM FOOD WHERE FOOD_CODE = "+food+"";
        String message = "Are you sure want to delete this menu profile ?";
        String title2 = "Confirmation?";
        // display the JOptionPane showConfirmDialog
        int reply = JOptionPane.showConfirmDialog(null, message, title2, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)//delete from database once the user click "YES"
        {
            try
            {
                stmt = con.createStatement();
                stmt.executeUpdate(query);
                JOptionPane.showMessageDialog(null, "Delete successful.");
            }
            catch (Exception ex)
            {
                //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(null, "Delete failed.");
            }
            clear2();
        }
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_delete2ActionPerformed

    // FIND DRINKS
    private void Find3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Find3ActionPerformed

       String Drink = FilledField3.getText();
       String query = "SELECT * FROM FOOD WHERE FOOD_CODE="+Drink+"";
       try
       {
            rset = getResultSet(query);
            if(rset.next())
            {
                FoodCode3.setText(rset.getString("FOOD_CODE"));
                FoodType3.setText(rset.getString("FOOD_TYPE"));
                FoodName3.setText(rset.getString("FOOD_NAME"));
                FoodPrice3.setText(rset.getString("FOOD_PRICE"));
            }
            else
            {
                JOptionPane.showMessageDialog(null, "INVALID DRINKS !");
            }
        } 
       catch (Exception ex)
       {
           //JOptionPane.showMessageDialog(null, "INVALID DRINKS.");
           //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
       }
    }//GEN-LAST:event_Find3ActionPerformed

    private void Reset3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Reset3ActionPerformed

        FoodCode3.setText("");
        FoodName3.setText("");
        FoodPrice3.setText("");
        FilledField3.setText("");
    }//GEN-LAST:event_Reset3ActionPerformed

    // ADD DRINKS
    private void add3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add3ActionPerformed

        String DrinkCode = FoodCode3.getText();
        String DrinkType = FoodType3.getText();
        String DrinkName = FoodName3.getText();
        String DrinkPrice= FoodPrice3.getText();
        String query = "INSERT INTO FOOD VALUES("+DrinkCode+",'"+DrinkType+"','"+DrinkName+"',"+DrinkPrice+")";
        String message = "Do you want to add a new detail ?";
        String TITLE = "Confirmation?";
        int reply = JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)
        {
            try
            {
              stmt = con.createStatement();
              stmt.executeUpdate(query);
              JOptionPane.showMessageDialog(null, "Add successful.");
              clear();
            }
            catch (Exception ex)
            {
              //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
              JOptionPane.showMessageDialog(null, "Add failed!\nDuplication is not allowed!");
            }
        }
        clear3();
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_add3ActionPerformed

    //UPDATE DRINKS
    private void update3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_update3ActionPerformed

        String DrinkCode = FoodCode3.getText();
        String DrinkType = FoodType3.getText();
        String DrinkName = FoodName3.getText();
        String DrinkPrice= FoodPrice3.getText();

        String query = "UPDATE FOOD SET FOOD_CODE = "+DrinkCode+",FOOD_TYPE = '"+DrinkType+"'"+
                        ",FOOD_NAME = '"+DrinkName+"',FOOD_PRICE = "+DrinkPrice+" WHERE FOOD_CODE = "+DrinkCode+"";
        String message = "Do you want to update the new detail ?";
        String TITLE = "Confirmation?";

        int reply = JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)
        {
            try
            {
                    stmt = con.createStatement();
                    stmt.executeUpdate(query);
                    JOptionPane.showMessageDialog(null, "Update successful.");
            }
            catch (Exception ex)
            {
                    //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(null, "Update failed!\nDuplication is not allowed!");
            }
        }
        clear3();
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_update3ActionPerformed

    // DELETE DRINKS
    private void delete3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delete3ActionPerformed

        food = FilledField3.getText();
        String query = "DELETE FROM FOOD WHERE FOOD_CODE = "+food+"";
        String message = "Are you sure want to delete this menu profile ?";
        String title2 = "Confirmation?";
        // display the JOptionPane showConfirmDialog
        int reply = JOptionPane.showConfirmDialog(null, message, title2, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION)//delete from database once the user click "YES"
        {
            try
            {
                stmt = con.createStatement();
                stmt.executeUpdate(query);
                JOptionPane.showMessageDialog(null, "Delete successful.");
            }
            catch (Exception ex)
            {
                JOptionPane.showMessageDialog(null, "Delete failed.");
                //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
            }
            clear3();
        }
        FoodArea.setText("");
        takeout();
    }//GEN-LAST:event_delete3ActionPerformed


    // USED TO APPEND THE " FOOD AREA "
    private void takeout()
    {
        try
        {
            String query = "SELECT * FROM FOOD";
            stmt = con.createStatement();
            rset = getResultSet(query);
            while(rset.next())
           {
            FoodArea.append(rset.getInt(1) + newline);
           }
        } 
        catch (Exception ex)
        {
            System.out.println("Failed to take out.");
            //Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private ResultSet getResultSet(String s)
    {
        connectDatabase();
        ResultSet rs = null;
        try
        {
            stmt = con.createStatement();
            rs = stmt.executeQuery(s);
        } 
        catch (SQLException ex)
        {
            Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }
/*
    private void connectDatabase() throws SQLException
    {
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
        System.out.println("Driver Loaded");
        con = DriverManager.getConnection(url,pass_id,pass_pw);
        System.out.println("Database Connected");
    }
  */
    private void connectDatabase()
    {
        try
        {
            Class.forName("oracle.jdbc.OracleDriver");
            con=DriverManager.getConnection(url, userID, userPW);
        }
        catch (ClassNotFoundException ex)
        {
            Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (SQLException ex)
        {
            Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void clear()
    {
        FoodCode.setText("");
        FoodName.setText("");
        FoodPrice.setText("");
        APPfield.setText("");
    }
    private void clear1()
    {
        FoodCode1.setText("");
        FoodName1.setText("");
        FoodPrice1.setText("");
        MDfield.setText("");
    }

    private void clear2()
    {
        FoodCode2.setText("");
        FoodName2.setText("");
        FoodPrice2.setText("");
        FilledField2.setText("");
    }

    private void clear3()
    {
        FoodCode3.setText("");
        FoodName3.setText("");
        FoodPrice3.setText("");
        FilledField3.setText("");
    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
            new MENU_EDIT().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField APPfield;
    private javax.swing.JPanel AppPane;
    private javax.swing.JTabbedPane CategoryTabbedPane;
    private javax.swing.JPanel DessertPane;
    private javax.swing.JButton DoneButton;
    private javax.swing.JPanel DrinkPane;
    private javax.swing.JTextField FilledField2;
    private javax.swing.JTextField FilledField3;
    private javax.swing.JButton Find;
    private javax.swing.JButton Find1;
    private javax.swing.JButton Find2;
    private javax.swing.JButton Find3;
    private javax.swing.JTextArea FoodArea;
    private javax.swing.JTextField FoodCode;
    private javax.swing.JTextField FoodCode1;
    private javax.swing.JTextField FoodCode2;
    private javax.swing.JTextField FoodCode3;
    private javax.swing.JTextField FoodName;
    private javax.swing.JTextField FoodName1;
    private javax.swing.JTextField FoodName2;
    private javax.swing.JTextField FoodName3;
    private javax.swing.JTextField FoodPrice;
    private javax.swing.JTextField FoodPrice1;
    private javax.swing.JTextField FoodPrice2;
    private javax.swing.JTextField FoodPrice3;
    private javax.swing.JTextField FoodType;
    private javax.swing.JTextField FoodType1;
    private javax.swing.JTextField FoodType2;
    private javax.swing.JTextField FoodType3;
    private javax.swing.JTextField MDfield;
    private javax.swing.JPanel MainDishPane;
    private javax.swing.JButton Reset;
    private javax.swing.JButton Reset1;
    private javax.swing.JButton Reset2;
    private javax.swing.JButton Reset3;
    private javax.swing.JComboBox SearchBy4;
    private javax.swing.JPanel ViewAllPane;
    private javax.swing.JButton add;
    private javax.swing.JButton add1;
    private javax.swing.JButton add2;
    private javax.swing.JButton add3;
    private javax.swing.JButton delete;
    private javax.swing.JButton delete1;
    private javax.swing.JButton delete2;
    private javax.swing.JButton delete3;
    private javax.swing.JLabel indication;
    private javax.swing.JLabel indication1;
    private javax.swing.JLabel indication2;
    private javax.swing.JLabel indication3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLayeredPane jLayeredPane2;
    private javax.swing.JLayeredPane jLayeredPane3;
    private javax.swing.JLayeredPane jLayeredPane4;
    private javax.swing.JLayeredPane jLayeredPane5;
    private javax.swing.JLayeredPane jLayeredPane6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton update;
    private javax.swing.JButton update1;
    private javax.swing.JButton update2;
    private javax.swing.JButton update3;
    // End of variables declaration//GEN-END:variables

}
